package com.rose.controller;


import com.rose.entity.Dept;
import com.rose.service.DeptClientService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

import java.util.List;

@RestController
public class DeptConsumerController {


    // 消费者，不应该有service层
    // RestTemplate ......供我们直接调用 注册到spring中
    @Autowired
    private DeptClientService deptClientService;  //因为确实没有实现类，所以此处填null

    @RequestMapping("/consumer/dept/add")
    public int add(Dept dept){
        return this.deptClientService.addDept(dept);
    }


    @RequestMapping("/consumer/dept/get/{id}")
    public Dept get(@PathVariable("id") Long id){
        return this.deptClientService.queryById(id);  //难道是这块必须加点吗  太难受了吧
    }

    @RequestMapping("/consumer/dept/list")
    public List<Dept> list(){
        return this.deptClientService.queryAll();
    }



}
